<template>
  <div class="newsDetails_container">
    <div class="details_title">
      <h1>{{title}}</h1>
      <!-- <p class="source">{{source}}</p> -->
      <p class="time">{{time}}</p>
    </div>
    <el-row :gutter="10">
      <el-col :xs="16" :sm="16" :md="16" :lg="16" :xl="16">
        <div class="left_item">

          <div class="details" v-html="content">{{content}}
          </div>

        </div>
      </el-col>

      <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8" class="right">
        <div class="right_item infinite-list" v-infinite-scroll="load" style="overflow:auto">
          <div class="infinite-list-item clearfix right_list">
            <div class="name">
              <p>
                最新文章
              </p>
              <i></i>

            </div>

            <ul>
              <li class="text-1" @click="details(item.id)" v-for="(item,index) in lawList.slice(0, 8)" :key="index">{{item.title}}</li>
            </ul>

          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import path from '@/network'
export default {
  name: 'App',
  data () {
    return {
      count: 0,
      title: '',
      time: '',
      source: '',
      content: '',
      lawList: [],
      total: 0,
      pagesize: 50,
      currentPage: 1,
    };
  },
  mounted () {
    this.getlawDetails(this.$route.query.secondId);
    //this.getLawList(this.$route.query.firstId);
    this.getSecondType(this.$route.query.firstId);


  },

  methods: {
    load () {
      this.count += 2
    },
    //获取list
    getlawDetails (id) {
      path.getlawDetails(
        id
      ).then(res => {
        if (res.success === 0) {
          this.title = res.rows.title
          this.time = res.rows.createTime
          this.source = res.rows.profiles
          this.content = res.rows.content
        }

      })
    },

    //获取list
    getLawList (id) {
      path.getLawList(
        this.currentPage,
        this.pagesize,
        id
      ).then(res => {
        if (res.success === 0) {
          this.lawList = res.rows;
        }

      })
    },

    getSecondType (id) {
      path.getSecondType(
        id
      ).then(res => {
        if (res.success === 0) {
          this.tabsData = res.rows;
          if (res.rows) {
            this.getLawList(res.rows[0].id);
          }

        }

      })
    },

    details: function (id) {
      this.getlawDetails(id)
    },

  }
}
</script>